//
//  TestCollectionPageVC.swift
//  CooperSwift_Example
//
//  Created by 计海峰 on 2021/11/4.
//  Copyright © 2021 CocoaPods. All rights reserved.
//

import UIKit
import RxSwift
import CooperSwift
import Then

class TestCollectionPageVM: NSObject, CollectionViewModelProtocol, RefreshControllable {
    
    func configDown() {
        print("TestPageContent3VM configDown")
        addFirstSectionItems([
            TestCollectionCellModel.initWith("测试1", size: CGSize(80, 120)).addTargetKey(bindKey()),
            TestCollectionCellModel.initWith("测试2").addTargetKey(bindKey()),
            TestCollectionCellModel.initWith("测试1").addTargetKey(bindKey()),
            TestCollectionCellModel.initWith("测试2").addTargetKey(bindKey()),
            TestCollectionCellModel.initWith("测试1", size: CGSize(80, 120)).addTargetKey(bindKey()),
            TestCollectionCellModel.initWith("测试2").addTargetKey(bindKey()),
            TestCollectionCellModel.initWith("测试1").addTargetKey(bindKey()),
            TestCollectionCellModel.initWith("测试2").addTargetKey(bindKey()),
        ])
    }
    
//    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
//        return vm_collectionView(collectionView, layout: collectionViewLayout, sizeForItemAt: indexPath)
//    }
    
    @objc func sumbit()  {
        log.debug("sumbit")
    }
    
    func refresh() {
        log.debug("TestPageContent3VM refresh")
        PublicMethod.delay(2) {
            self.rx.refreshStatus.onNext(.endHeaderRefresh)
        }
    }
    
}

class TestCollectionPageVC: UIViewController, CollectionEnableProtocol {
    
    let disposeBag = DisposeBag()

    let vm = ViewModelFactory.collectionVM(TestCollectionPageVM.self)
    
    override func viewDidLoad() {
        super.viewDidLoad()
        configAll(vm, disposeBag: disposeBag, flowLayout:  UICollectionViewFlowLayout.init().defaultLayout())
        // Do any additional setup after loading the view.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destination.
        // Pass the selected object to the new view controller.
    }
    */

}
